/**
 * 报表的最终数据结构
 */

import { EAxisType, EAxisChartDimension } from "@/Charts/index"
import { IReportConfig } from "@/Charts/Charts";

const ReportConfig: IReportConfig = {
    chartStructureGroup: [
        [
            { id: "chart1", active: true },
            { id: "chart2", active: false }
        ],
        [{ id: "chart3", active: true }],
        [{ id: "chart4", active: true }]
    ],
    
    charts: {
        chart1: {
            container: "component1",
            id: "chart1",
            chartType: 1,
            dataSourceURL: "https://www.fastmock.site/mock/f0ae2cb1541305cefa1b7d31b3cc6d13/api/api/getDataList",
            mateDataURL: "https://www.fastmock.site/mock/f0ae2cb1541305cefa1b7d31b3cc6d13/api/api/getDataList",
            parent: "",
            ChartOptions: {
                xAxis: {
                    type: EAxisType.Category,
                    data: ["星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期天"]
                },
                yAxis: {
                    type: EAxisType.Value
                },
                series: [{
                    data: [10, 23, 34, 78, 23, 67, 123],
                    type: EAxisChartDimension.Line,
                    areaStyle: {}
                }, {
                    data: [10, 23, 34, 78, 23, 67, 123],
                    type: EAxisChartDimension.Line,
                }, {
                    data: [10, 23, 34, 78, 23, 67, 123],
                    type: EAxisChartDimension.Bar,
                }]
            },
            events: {
                "button1": {
                    //redirect后，所属的结构组中被redirect的元素，active为true，其余都是false
                    type: "redirect",
                    target: "chart4",
                    params: {
                        id: 5
                    }
                }
            }
        },
        chart2: {
            container: "component2",
            id: "chart2",
            title: "我看起来是chart1，其实已经重绘到chart2.点击按钮联动我右边的chart3",
            parent: "chart1",
            chartType: 2,
            dataSourceURL: "https://www.fastmock.site/mock/f0ae2cb1541305cefa1b7d31b3cc6d13/api/api/getDataList",
            mateDataURL: "https://www.fastmock.site/mock/f0ae2cb1541305cefa1b7d31b3cc6d13/api/api/getDataList",
            ChartOptions: {},
            events: {
                "button1": {
                    type: "setFilter",
                    target: "chart3",
                    params: {
                        id: 3
                    }
                }
            }
        },
        chart3: {
            container: "component3",
            id: "chart3",
            parent: "chart2",
            chartType: 3,
            dataSourceURL: "https://www.fastmock.site/mock/f0ae2cb1541305cefa1b7d31b3cc6d13/api/api/getDataList",
            mateDataURL: "https://www.fastmock.site/mock/f0ae2cb1541305cefa1b7d31b3cc6d13/api/api/getDataList",
            ChartOptions: {},
            events: {
                "button1": {
                    type: "setFilter",
                    target: "chart4",
                    params: {
                        id: 3
                    }
                }
            }
        },
        chart4: {
            container: "component4",
            id: "chart4",
            parent: "chart3",
            chartType: 4,
            ChartOptions: {
                title: {
                    // text: 'Basic Radar Chart'
                    text: 'Basic Radar Chart'
                },
                legend: {
                    data: `return $originData.map(data=>{
                        return data.student_name;
                    })`
                    // data: ['Allocated Budget', 'Actual Spending']
                },
                radar: {
                    // shape: 'circle',
                    indicator:`
                        return $originData.map(data=>{
                            return {
                                name: data.student_name,
                                max: 100
                            }
                        })
                    `,
                    //"#[Array<{name: '*student_name', max: 30000}>]",
                    // `(function(originData){
                    //     return originData.map(data=>{
                    //         return {
                    //             name: data.name,
                    //             max: 30000
                    //         }
                    //     })
                    // })(originData)`,//`策略名称，取值字段，结果类型，取值`,
                    // indicator: [
                    //     { name: 'Sales', max: 6500 },
                    //     { name: 'Administration', max: 16000 },
                    //     { name: 'Information Technology', max: 30000 },
                    //     { name: 'Customer Support', max: 38000 },
                    //     { name: 'Development', max: 52000 },
                    //     { name: 'Marketing', max: 25000 }
                    // ]
                },
                // "name": "ch_score",
                // "name": "math_score",
                // "name": "eng_score",
                // "name": "history_score",
                // "name": "biology_score",
                series: [
                    {
                        name: 'Budget vs spending',
                        type: 'radar',
                        data:`return $originData.map(seriesData=>{
                            return {
                                value:[seriesData.ch_score,seriesData.math_score,seriesData.eng_score,seriesData.history_score,seriesData.biology_score],
                                name: seriesData.student_name
                            }
                        });`
                        // #[Array<{
                        //     value:Array<*ch_score,*math_score,*eng_score,*history_score,*biology_score>,
                        //     name: *student_name
                        // }>]`,
                        /**
                        "#[Array<{value:Array<*ch_score,*math_score,*eng_score,*history_score,*biology_score>,name: *student_name}>]"
                         */
                        // ddd:[
                        //     {
                        //         value: "#[Array<*ch_score,*math_score,*eng_score,*history_score,*biology_score>]",
                        //         name: 'Allocated Budget'
                        //     },
                        //     {
                        //         value: "#[Array<*dataName>]",
                        //         name: 'Actual Spending'
                        //     }
                        // ]
                    }
                ]
            },
            dataSourceURL: "https://www.fastmock.site/mock/f0ae2cb1541305cefa1b7d31b3cc6d13/api/api/getDataList",
            mateDataURL: "https://www.fastmock.site/mock/f0ae2cb1541305cefa1b7d31b3cc6d13/api/api/getDataList"
        }
    }
};

export default ReportConfig;